const Sequelize = require("sequelize");
const { host, user, password, database, port } = require("../config").db.mysql;

//  创建连接对象，并模块化
// var sequelize = new Sequelize(database, user, password, {
//   host: host,
//   port: port, // mysql默认端口
//   dialect: "mysql",
//   pool: {
//     max: 10,
//     min: 0,
//     idle: 10000
//   }
// });

const sequelize = new Sequelize(
  `mysql://${user}:${password}@${host}:${port}/${database}`,
  {
    logging: false,
    pool: {
      max: 100,
      min: 0,
      idle: 5000
    },
    //解决中文输入问题
    define: {
      underscored: true,
      charset: "utf8mb4"
    }
  }
);
module.exports = sequelize;
